def is_valid_sequence(sequence):
  stack = []
  opening_brackets = ['(', '[', '{', '<']
  closing_brackets = [')', ']', '}', '>']

  for bracket in sequence:
      if bracket in opening_brackets:
          stack.append(bracket)
      elif bracket in closing_brackets:
          if not stack:
              return False
          last_opening_bracket = stack.pop()
          if opening_brackets.index(last_opening_bracket) != closing_brackets.index(bracket):
              return False

  if stack:
      return False
  else:
      return True

sequence = input("Введите скобочную последовательность: ")
print(is_valid_sequence(sequence))